package com.jinmdz.fmis.dao.admin.dao;

import com.jinmdz.fmis.dao.admin.model.button.ButtonEditItem;
import com.jinmdz.fmis.dao.admin.model.button.ButtonListItem;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;

/**
 * 菜单按钮维护Dao
 *
 * @author LiCongLu
 * @date 2020-03-18 16:59
 */
public interface ButtonDao {

    /**
     * 按照系统菜单主键查询菜单按钮列表
     *
     * @param businessSystemMenuId 菜单主键
     * @return
     * @author LiCongLu
     * @date 2020-03-18 16:59
     */
    @Select(" select id,business_system_menu_id,button_name,button_describe,disable_state,sort,remark,version " +
            " from business_system_menu_button where business_system_menu_id = #{businessSystemMenuId} and deleted = 0 ")
    ArrayList<ButtonListItem> listButtonListByBusinessSystemMenuId(@Param("businessSystemMenuId") Integer businessSystemMenuId);

    /**
     * 按照主键获取菜单按钮信息
     *
     * @param id 主键
     * @return
     * @author LiCongLu
     * @date 2020-03-18 17:01
     */
    @Select(" select id,business_system_menu_id,button_name,button_describe,disable_state,sort,remark,version" +
            " from business_system_menu_button where id = #{id} and deleted = 0 limit 1 ")
    ButtonEditItem getButtonEditById(@Param("id") Integer id);

    /**
     * 按照菜单按钮名称查询非当前菜单按钮信息主键
     *
     * @param buttonId             当前菜单按钮主键
     * @param businessSystemMenuId 菜单主键
     * @param buttonName           菜单按钮编码
     * @return
     * @author LiCongLu
     * @date 2020-03-16 10:51
     */
    @Select(" select id from business_system_menu_button where id != IFNULL(#{buttonId},0) and business_system_menu_id = #{businessSystemMenuId} and button_name = #{buttonName} and deleted = 0 limit 1 ")
    @ResultType(Integer.class)
    Integer getButtonIdByButtonName(@Param("buttonId") Integer buttonId, @Param("businessSystemMenuId") Integer businessSystemMenuId, @Param("buttonName") String buttonName);
}
